package com.edu.exam.enums.assessment.technical;

/**
 * 相似度级别枚举
 *
 * @author System
 * @version 1.0
 * @since 2025-11-15
 */
public enum SimilarityLevel {
    /**
     * 不相似
     */
    NOT_SIMILAR("不相似", 0.0, 0.3999),

    /**
     * 低度相似
     */
    LOW_SIMILARITY("低度相似", 0.4, 0.5999),

    /**
     * 中度相似
     */
    MODERATELY_SIMILAR("中度相似", 0.6, 0.7999),

    /**
     * 高度相似
     */
    HIGHLY_SIMILAR("高度相似", 0.8, 1.0);

    private final String description;
    private final double minScore;
    private final double maxScore;

    SimilarityLevel(String description, double minScore, double maxScore) {
        this.description = description;
        this.minScore = minScore;
        this.maxScore = maxScore;
    }

    public String getDescription() {
        return description;
    }

    public double getMinScore() {
        return minScore;
    }

    public double getMaxScore() {
        return maxScore;
    }

    /**
     * 根据相似度分数获取级别
     *
     * @param score 相似度分数
     * @return 相似度级别
     */
    public static SimilarityLevel fromScore(double score) {
        if (score >= HIGHLY_SIMILAR.minScore) {
            return HIGHLY_SIMILAR;
        } else if (score >= MODERATELY_SIMILAR.minScore) {
            return MODERATELY_SIMILAR;
        } else if (score >= LOW_SIMILARITY.minScore) {
            return LOW_SIMILARITY;
        } else {
            return NOT_SIMILAR;
        }
    }
}